<?php
/**
 * Created by PhpStorm.
 * User: xiangpeng
 * Date: 2016/12/25
 * Time: 13:12
 */

namespace Admin\Controller;
use Common\Model\UserModel;
use Think\Controller;

class LoginController extends  Controller
{
    //登录方法首页
    public function index(){
        //2.创建模型中模型类
        if(IS_POST){ //3。判断是否是post提交
            // 实例化user模型类
            $userModel=  new UserModel() ;
            //4.先验证验证码
            if($userModel->isLogin()){
                $this->success('登录成功',U('Admin/Index/index'));die;
            }else{
                $this->error($userModel->getError());die;
            }

        }
        //1.载入模板
        $this->display();
    }


    //验证码类
    public function code(){
        //动态设置的方式
        $Verify =     new \Think\Verify();
        $Verify->fontSize = 30;
        $Verify->length   = 3;
        $Verify->useNoise = false;
        $Verify->entry();
    }
    public function out(){
        //清空当前session
        session(null);
        //销毁session
        session('[destroy]');
        //退出成功提示
        $this->success('退出成功',U('Admin/Login/index'));
    }

}